
(function () {
    Codestrong.ui.createVideoPlayWindow = function (settings) {
    	var aps='';
  	 if(Codestrong.isAndroid()) {
  	 	   Titanium.include('../globals.js');
  	 	   aps='../';
  	 	}
     else 	{
     	Titanium.include('globals.js');
     } 
       
    
   
    
     var win = Titanium.UI.createWindow({
            id: 'VideoWindow',
            title: 'XEM BÀI GIẢNG',
            backgroundColor: '#FFF',
            barColor: '#414444',
            fullscreen: false,
            orientationModes:[Ti.UI.LANDSCAPE_LEFT]
        });
       
    var egc = new globals.EventGarbageCollection(win);
    egc.addEventListener('back_VideoWindow', function () {
 		
 		Codestrong.navGroup.close(win, {
                        animated: true
        });
        
	});
     
    ////////////main_header///////////////////////////
     var databutton_right=[
    	//{Id:1,Image:aps+'images/list_bullets.png',Image_:aps+'images/list_bullets_.png',tag:'Category'},
	    {Id:2,Image:aps+'images/account.png',Image_:aps+'images/account_.png',tag:'Login'},
	    //{Id:3,Image:aps+'images/search.png',Image_:aps+'images/search_.png',tag:'Search'},
	    
	]
	/*
	var main_header=require('controls/main_header').main_header({
	 		backgroundImage: aps+'images/panel3.png',
	 		headertext:'Thầy trò Mobile: Xem bài giảng',
		    left: 0,
		    top: 0,
		    height:65,
		    width: Globals.platformWidth,
		    touchEnabled: true		,
		    databutton_right:databutton_right,
		    imback:   aps+'images/back.png',
		    imback_:   aps+'images/back_.png',
		    idWinParent:'VideoWindow'
		    
    })

	win.add(main_header);
     */
     
     
     var activeMovie = Titanium.Media.createVideoPlayer({
       top:0,//main_header.top+main_header.height,
       url:settings.VideoUrl,
       backgroundColor:'#111',
       movieControlMode:Titanium.Media.VIDEO_CONTROL_DEFAULT, // See TIMOB-2802, which may change this property name
 	   scalingMode:Titanium.Media.VIDEO_SCALING_MODE_FILL,
 	    layout:'horizontal'
 	   
    });

    win.add(activeMovie);
    var windowClosed = false;
    var dlg = Titanium.UI.createActivityIndicator();
    win.addEventListener('open',function()
    {
           dlg.setMessage(Globals.loadingvideo);
           dlg.show();
    });

    activeMovie.addEventListener('load',function()
    {
           dlg.hide();
    });

    activeMovie.addEventListener('complete',function()
    {
           win.close();
           
          
    });

    activeMovie.play();

    win.addEventListener('close', function() 
    {
           windowClosed = true;
           activeMovie.stop();
    });
        
  	 return win;
    };
})();